package com.lfd.mqttv3;

import com.lfd.mqttv3.mqtt.MqttPublisher;
import com.lfd.mqttv3.mqtt.MqttSubscriber;
import com.lfd.mqttv3.properties.MqttProperties;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Mqttv3Application implements CommandLineRunner {
    @Autowired
    private MqttSubscriber mqttSubscriber;
    @Autowired
    private MqttPublisher mqttPublisher;
    @Autowired
    private MqttProperties mqttProperties;
    @Value("${test.text}")
    private String text;

    @Override
    public void run(String... args) throws Exception {
        mqttSubscriber.subscribe(mqttProperties.getSendTopic());
        mqttPublisher.mqttClient("创建MQTT客户端",2);
        System.out.println("text===:"+text);
    }

    public static void main(String[] args) {
        SpringApplication.run(Mqttv3Application.class, args);
    }

}
